Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter remove all #145

Merged
merged 2 commits into from
Sep 13, 2023
Merged

Conversation

rrrkren
Copy link
Contributor

@rrrkren rrrkren commented Aug 10, 2023

added method removeAllTypes() for AllowListFilter and DenyListFilter

/// Removes all types from the mapping of denied types
///
pub fun removeAllTypes() {
for type in self.deniedTypes.keys {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead make deniedTypes a var and just set it to an empty array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will that be backward compatible change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the events might be nice to have?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably have an event that says types cleared to make it more efficient. and lemme check if it's a backward compatible change, my gut says no

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will that be backward compatible change

I believe changing let to var is an an upgradable change yes

also the events might be nice to have?

👍 Sure, totally fine to add events. That might require some discussion so if you need some way to remove types right now for testing purposes, I'd split them up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth it to do the let/var change if we want to iterate through every key to emit each event?

Copy link
Collaborator

@sisyphusSmiling sisyphusSmiling Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be helpful for each removed type to be included in its own event or could we emit an array of removed types? If the latter, I think we could use the same event for both removal operations and just emit the dict keys

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emitting an array is what I was thinking, yeah. It depends on what kinds of events you're thinking about @rrrkren. Is there any high-level thought on that yet that we can use to think through this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what we are doing right now to reset filters:

        let filterDetails = filter.getDetails() as! {String:AnyStruct}
        for allowedType in filterDetails["allowedTypes"]! as! [Type]{
            filter.removeType(allowedType)
        }

I'd prefer to keep this PR as is if possible since it's just a sugared iterate remove all and doesn't require downstream event aggregations to change. Happy to discuss further on the single filter reset event as a follow up.

@austinkline
Copy link
Collaborator

Checking in on this PR. @rrrkren any updates? If we need to have a quick call to get a plan together for it give me a shout! Happy to do so

@austinkline
Copy link
Collaborator

Approved, but looks like we have a failing test to fix:
testAllowlistFilterRemoveAllTypes

var filePath = ""
switch kind {
case FilterKindAllowList:
filePath = "filter/allow/remove_all_types.cdc"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the file needs to be renamed - remoe_all_types.cdc -> remove_all_types.cdc. Small typo is causing this test case to fail

@sisyphusSmiling sisyphusSmiling merged commit 0ddf6b8 into onflow:main Sep 13, 2023
@sisyphusSmiling
Copy link
Collaborator

CapabilityFilter contract updated on Testnet & Mainnet in the following transactions:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants